package com.jdcjk.project.main.view;

import android.annotation.SuppressLint;
import android.app.DialogFragment;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

import com.jdcjk.R;

/**
 * Created by Administrator on 2017/2/20 0020.
 */
@SuppressLint({"NewApi", "ValidFragment"})
public class UpdataAppDialog extends DialogFragment {
    private final String TAG = BindCarDialog.class.getSimpleName();
    private Context context;
    private String url;
    private EditText sim_editText;
    //确定按钮
    private Button updataAppDetermine_button;

    public UpdataAppDialog(Context context, String url) {
        this.context = context;
        this.url = url;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View viewContent = inflater.inflate(R.layout.dialog_updata_app, container, false);
        //去掉dialog默认标题
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        //确定按钮
        updataAppDetermine_button = (Button) viewContent.findViewById(R.id.dialog_updata_app_determine_btn);
        updataAppDetermine_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //确定按钮点击监听
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                //如果有新版本，则通过浏览器打开二维码网址
                Uri appQRCodeUrl = Uri.parse(url);
                intent.setData(appQRCodeUrl);
                startActivity(intent);
                UpdataAppDialog.this.dismiss();
            }
        });
        //取消按钮
        Button addCarCancle_button = (Button) viewContent.findViewById(R.id.dialog_updata_app_cancle_btn);
        //取消按钮点击监听
        addCarCancle_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UpdataAppDialog.this.dismiss();
            }
        });
        return viewContent;
    }


}
